package archforce.atp.x.ssh.entity;

import com.alibaba.fastjson.JSON;

import java.io.Serializable;
import java.util.List;

/**
 * @author wx
 * @version 1.0
 * @date 2022/4/27 11:10
 */
public class JumpConfig implements Serializable {
    private List<ServerEntity> jumpHost;

    private ServerEntity dockerCMasterServer;

    public JumpConfig(List<ServerEntity> jumpHost) {
        this.jumpHost = jumpHost;
    }

    public JumpConfig(List<ServerEntity> jumpHost, ServerEntity dockerCMasterServer) {
        this.jumpHost = jumpHost;
        this.dockerCMasterServer = dockerCMasterServer;
    }

    public JumpConfig addJumpHost(ServerEntity host){
        this.jumpHost.add(host);
        return this;
    }

    public List<ServerEntity> getJumpHost() {
        return jumpHost;
    }

    public void setJumpHost(List<ServerEntity> jumpHost) {
        this.jumpHost = jumpHost;
    }

    public ServerEntity getDockerCMasterServer() {
        return dockerCMasterServer;
    }

    public void setDockerCMasterServer(ServerEntity dockerCMasterServer) {
        this.dockerCMasterServer = dockerCMasterServer;
    }

    public void setDockerCMasterServer(String hostIP, String user, String password) {
        ServerEntity master = new ServerEntity(hostIP, user, password);
        this.dockerCMasterServer = master;
    }

    public static class ServerEntity implements Serializable{
        private String hostIP;
        private Integer port =22;
        private String user;
        private String password;

        public ServerEntity(String hostIP, String user, String password) {
            this.hostIP = hostIP;
            this.user = user;
            this.password = password;
        }

        public String getHostIP() {
            return hostIP;
        }

        public void setHostIP(String hostIP) {
            this.hostIP = hostIP;
        }

        public Integer getPort() {
            return port;
        }

        public void setPort(Integer port) {
            this.port = port;
        }

        public String getUser() {
            return user;
        }

        public void setUser(String user) {
            this.user = user;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public ServerEntity(String hostIP, Integer port, String user, String password) {

            this.hostIP = hostIP;
            this.port = port;
            this.user = user;
            this.password = password;
        }

        @Override
        public String toString() {
            return JSON.toJSONString(this, true);
        }
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this, true);
    }
}
